package com.foreknow.elm.controller;

import com.foreknow.elm.po.User;
import com.foreknow.elm.service.UserService;
import com.foreknow.elm.service.impl.UserServiceImpl;

import javax.servlet.http.HttpServletRequest;

public class UserController {
    // UserController/getUserByIdByPass?userId=12345671111&password=123
    public User getUserByIdByPass(HttpServletRequest request){
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        UserService userService = new UserServiceImpl();
        User user = userService.getUserByIdByPass(userId,password);
        return user;
    }

    // UserController/getUserById?userId=12345671111
    public int getUserById(HttpServletRequest request){
        String userId = request.getParameter("userId");
        UserService userService = new UserServiceImpl();
        int i = userService.getUserById(userId);
        return i;
    }

    //UserController/saveUser?userId=4444444445&password=123431&userName=没评&userSex=1
    public int saveUser(HttpServletRequest request) {
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        String userName = request.getParameter("userName");
        Integer userSex = Integer.parseInt(request.getParameter("userSex"));
        UserService userService = new UserServiceImpl();
        int i = userService.saveUser(userId,password,userName,userSex);
        return i;
    }

}
